package net.bwie.jtp.mapper;

import net.bwie.jtp.bean.TrafficChannelAvgBean;
import net.bwie.jtp.bean.TrafficChannelPvBean;
import net.bwie.jtp.bean.TrafficChannelUvBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 简介说明:
 *
 * @author: LiLi
 * @date: 2025/05/21 15:11:16
 * @version: 1.0
 */
public interface TrafficChannelStatsMapper {

        @Select("select\n" +
                "    channel,\n" +
                "    sum(pv_count) as pv_count\n" +
                "from jtp_log_report.dws_traffic_page_view_window_report\n" +
                "where toDate(window_start_time) = #{date}\n" +
                "group by channel")

        List<TrafficChannelPvBean> selectPvCount(@Param("date") String date);


        @Select("select\n" +
                "    channel,\n" +
                "    sum(uv_count) as uv_count\n" +
                "from jtp_log_report.dws_traffic_page_view_window_report\n" +
                "where toDate(window_start_time) = #{date}\n" +
                "group by channel")

        List<TrafficChannelUvBean> selectUvCount(@Param("date") String date);


        @Select("SELECT\n" +
                "    channel,\n" +
                "    sum(pv_during_time)/sum(session_count) as avg_session_duration\n" +
                "FROM jtp_log_report.dws_traffic_page_view_window_report\n" +
                "WHERE toDate(window_start_time) = #{date}\n" +
                "GROUP BY channel")


        List<TrafficChannelAvgBean> selectAvgCount(@Param("date") String date);


}


